package com.pks.shun.myapplication.crop;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import com.pks.shun.myapplication.R;

import java.io.IOException;

public class Main2Activity extends AppCompatActivity {

    private ImageView mImage;
    private CropCoverDrawable bg;
    private CropHelper helper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        init();

    }

    private void init() {
        mImage = (ImageView) findViewById(R.id.mImg);
        bg = new CropCoverDrawable(500, 500);
        bg.setShape(CropPath.SHAPE_CIRCLE);
//        mCover = findViewById(R.id.mCover);
//        mCover.setBackgroundDrawable(bg);
        helper = new CropHelper().attractTo(mImage);
        helper.setCropPath(bg);

        //裁剪
        Bitmap bmp = helper.crop();
         //裁剪并保存
        try {
            String savePath = helper.cropAndSave(getFilesDir().getAbsolutePath() + "/temp.png");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
